package com.beteng.su.betengsu.ui.fragment.task;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.AppCompatEditText;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.widget.TextView;

import com.beteng.su.betengsu.R;
import com.beteng.su.betengsu.adapter.FullyGridLayoutManager;
import com.beteng.su.betengsu.adapter.GridImageAdapter;
import com.beteng.su.betengsu.adapter.OrderInputAdapter;
import com.beteng.su.betengsu.base.BaseActivity;
import com.beteng.su.betengsu.bean.BaseBean;
import com.beteng.su.betengsu.bean.OrderBean;
import com.beteng.su.betengsu.bean.SpinnerBeanCla;
import com.beteng.su.betengsu.net.webservice.SiteService;
import com.beteng.su.betengsu.utils.CommonUtils;
import com.beteng.su.betengsu.utils.DateTimeUtils;
import com.beteng.su.betengsu.utils.FileUtils;
import com.beteng.su.betengsu.widget.AutoToolbar;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.SnackbarUtils;
import com.goyourfly.multiple.adapter.MultipleAdapter;
import com.goyourfly.multiple.adapter.MultipleSelect;
import com.goyourfly.multiple.adapter.menu.MenuBar;
import com.goyourfly.multiple.adapter.viewholder.view.RadioBtnFactory;
import com.jaredrummler.materialspinner.MaterialSpinner;
import com.jzxiang.pickerview.TimePickerDialog;
import com.jzxiang.pickerview.data.Type;
import com.jzxiang.pickerview.listener.OnDateSetListener;
import com.luck.picture.lib.PictureSelector;
import com.luck.picture.lib.compress.Luban;
import com.luck.picture.lib.config.PictureConfig;
import com.luck.picture.lib.config.PictureMimeType;
import com.luck.picture.lib.entity.LocalMedia;
import com.zhy.autolayout.AutoRelativeLayout;

import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;
import cn.droidlover.xrecyclerview.RecyclerItemCallback;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;

import static com.luck.picture.lib.config.PictureConfig.LUBAN_COMPRESS_MODE;

/**
 * Created by chenzhimin on 2017/9/6.
 */

public class OrderInputActivity extends BaseActivity {

    public static final String SERACH_ITEM_SINGLE_INTENT = "SERACH_ITEM_SINGLE_INTENT";
    public static final String SERACH_ITEM_NUTIL_INTENT = "SERACH_ITEM_NUTIL_INTENT";


    @BindView(R.id.toolbar_back)
    AutoRelativeLayout mToolbarBack;
    @BindView(R.id.toolbar_title)
    TextView mToolbarTitle;
    @BindView(R.id.toolbar)
    AutoToolbar mToolbar;
    @BindView(R.id.order_input_rv)
    RecyclerView mOrderInputRv;
    private MultipleAdapter mAdapter;
    private GridImageAdapter mImageViewadapter;


    private GridImageAdapter adapter;

    private List<String> dataSourceList = new ArrayList<>();

    private List<LocalMedia> selectList;

    private List<OrderBean> mUsers = new ArrayList<>();

    //异常状态集合
    private static final ArrayList<SpinnerBeanCla> mSpinnerDatas  = new ArrayList<>();


    public static void start(Context context) {
        Intent starter = new Intent(context, OrderInputActivity.class);
        context.startActivity(starter);
    }

    @Override
    public void initData(Bundle savedInstanceState) {
        mToolbarTitle.setText(getTitle());


        final OrderInputAdapter orderSearchAdapter = new OrderInputAdapter(context);

        mAdapter  = MultipleSelect.with(this)
                .adapter(orderSearchAdapter)
                .decorateFactory(new RadioBtnFactory())
                .customMenu(new MyCustomMenuBar(this, Gravity.TOP))
                .build();

        showLoading();
        SiteService.getInstants().getOrders(getParams(1000),context)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<List<OrderBean>>() {
                    @Override
                    public void accept(final List<OrderBean> orderBeanList) throws Exception {
                        hideLoading();
                        orderSearchAdapter.setData(orderBeanList);
                        mUsers.clear();
                        mUsers.addAll(orderBeanList);
                        mAdapter.notifyDataSetChanged();
                        orderSearchAdapter.setRecItemClick(new RecyclerItemCallback<OrderBean, OrderInputAdapter.ViewHolder>() {
                            @Override
                            public void onItemClick(int position, OrderBean model, int tag, OrderInputAdapter.ViewHolder holder) {
                                super.onItemClick(position, model, tag, holder);
                                showInputChooseDialog(orderBeanList.get(position));
                            }

                            @Override
                            public void onItemLongClick(int position, OrderBean model, int tag, OrderInputAdapter.ViewHolder holder) {
                                super.onItemLongClick(position, model, tag, holder);

                            }
                        });
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        hideLoading();
                        SnackbarUtils.with(mToolbarTitle).setMessage(throwable.getMessage()).showWarning();
                        LogUtils.d("throwable:" + throwable.getMessage());
                    }
                });

        CommonUtils.configRecycleView(mOrderInputRv,new LinearLayoutManager(this));

        mOrderInputRv.setAdapter(mAdapter);


    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_order_input;
    }




    @OnClick(R.id.toolbar_back)
    public void onViewClicked() {
        finish();
    }


    private class MyCustomMenuBar extends MenuBar {

        Activity activity;
        private TextView mTVCout;

        public MyCustomMenuBar(Activity activity, int gravity) {
            super(activity, gravity);
            this.activity = activity;
        }

        @NotNull
        @Override
        public View getContentView() {
            View view = View.inflate(activity, R.layout.custom_control, null);
            mTVCout = (TextView)view.findViewById(R.id.title);
            TextView mTvInputGp = (TextView)view.findViewById(R.id.tv_waybill_input_mutil_group);
            TextView mTVcancel = (TextView)view.findViewById(R.id.cancel);

            mTVcancel.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    if (MyCustomMenuBar.this.getControler() != null) {
                        MyCustomMenuBar.this.getControler().done(true);
                    }
                }
            });

            mTvInputGp.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {

                    ArrayList<OrderBean> lists = new ArrayList<>();

                    for (int i = 0; i < mAdapter.getSelectNum(); i++) {
                        Integer integer = mAdapter.getSelect().get(i);
                        lists.add(mUsers.get(integer));
                    }
                    showInputMutilDialog(lists);
                }
            });



            return view;
        }

        @Override
        public void onUpdateTitle(int i, int i1) {
            mTVCout.setText("当前选中"+i+"条");
        }
    }



    private HashMap<String, Object> getParams(Integer page) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("PageSize", page);
        return params;
    }




    public void showInputChooseDialog(final OrderBean order) {
        AlertDialog dialog = new AlertDialog.Builder(this, AlertDialog.THEME_HOLO_LIGHT)
                .setTitle("请选择")
                .setItems(new String[]{"跟单录入", "签收录入", "异常录入"}, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        switch (i) {
                            case 0:
                                showInputDialog(order);
                                break;
                            case 1:
                                showSignDialog(order);
                                break;
                            case 2:
                                showInputErrorDialog(order);
                                break;
                            default:
                                break;
                        }
                    }
                }).show();


    }


    public void showInputDialog(OrderBean order) {
        Intent intent = new Intent(this, ItemDetailActivity.class);
        intent.setAction(SERACH_ITEM_NUTIL_INTENT);
        ArrayList<OrderBean> list = new ArrayList<>();
        list.add(order);
        intent.putParcelableArrayListExtra(SERACH_ITEM_NUTIL_INTENT,list);
        startActivity(intent);
    }

    public void showInputMutilDialog(ArrayList<OrderBean> orders) {
        Intent intent = new Intent(this, ItemDetailActivity.class);
        intent.setAction(SERACH_ITEM_NUTIL_INTENT);
        intent.putParcelableArrayListExtra(SERACH_ITEM_NUTIL_INTENT,orders);
        startActivity(intent);
    }


    public void showInputErrorDialog(final OrderBean order) {
        View view = View.inflate(this, R.layout.item_input_error, null);


        TextView signItemErrorGoodsbill = view.findViewById(R.id.sign_item_error_goodsbill);
        TextView signItemErrorBetengWaybill = view.findViewById(R.id.sign_item_error_beteng_waybill);
        final MaterialSpinner signItemErrorSpinner = view.findViewById(R.id.sign_item_error_spinner);
        final AppCompatEditText signItemErrorRemark = view.findViewById(R.id.sign_item_error_remark);
        TextView signItemErrorExample = view.findViewById(R.id.sign_item_error_example);
        RecyclerView signInputErrorDgv = view.findViewById(R.id.item_input_error_dgv);

        signItemErrorGoodsbill.setText(order.getSupplierWaybillNO()+"");
        signItemErrorBetengWaybill.setText(order.getWaybillID()+"");

        signItemErrorSpinner.setOnItemSelectedListener(new MaterialSpinner.OnItemSelectedListener() {
            @Override
            public void onItemSelected(MaterialSpinner view, int position, long id, Object item) {
                switch (position){
                    case -1:
                        signItemErrorRemark.setText("");
                        break;
                    case 1:
                        signItemErrorRemark.setText("收货人电话：1380000000空号，请提供其他联系方式。");
                        break;
                    case 2:
                        signItemErrorRemark.setText("因收货人提供派送地址为：山东省青岛市市北区辽宁路161号C区1单元302室，与开单地址：山东省青岛市胶南区不符，请核实确认派送地址");
                        break;
                    case 3:
                        signItemErrorRemark.setText("收货方电话联系人为：张三，与开单收货人：李四不相符，请核实确认收货人。");
                        break;
                    case 4:
                        signItemErrorRemark.setText("因我司操作失误贴错标签，导致其中1件窜货至天津，目前正在安排调货中。");
                        break;
                    case 5:
                        signItemErrorRemark.setText("因我司操作失误漏贴标签，导致其中2件丢失，目前还在查找中。");
                        break;
                    case 6:
                        signItemErrorRemark.setText("因我司卸货过程操作不当，其中3件货物到达北京发生外包装严重破损。");
                        break;
                    case 7:
                        signItemErrorRemark.setText("因此票货与我司实际交货件数（重量、体积、单价、费用）为10件，开单件数（重量、体积、单价、费用）11件，实际交货与开单不符。");
                        break;
                    case 8:
                        signItemErrorRemark.setText("此票货贵司要求签收回单原件2联，但实际交货随行单据仅一联（无签收单）。");
                        break;
                    case 9:
                        signItemErrorRemark.setText("因我司内部信息传导不当，导致此票货未做控货处理已派送至客户处，目前与收货方协调中");
                        break;
                    case 10:
                        signItemErrorRemark.setText("因收货方要求送货上楼（自提、卸货、送货上门），与开单不符，请核实确认客户需求");
                        break;
                    case 11:
                        signItemErrorRemark.setText("因收货人要求送货上3楼无电梯，现上楼费费用按3元每件标准计算，需补30元费用");
                        break;
                    case 12:
                        signItemErrorRemark.setText("因昨晚我司仓位不足，导致此票货未及时发出，预计今晚23:00发出");
                        break;
                    case 13:
                        signItemErrorRemark.setText("8月24日14:00至20:00在吉安因前方发生交通事故堵车，导致时效延误，预计26日凌晨到达");
                        break;
                    case 14:
                        signItemErrorRemark.setText("因下大雨中转公司未及时发车，导致货物未及时中转，预计24日22:00左右中转，25日12:00到达目的站。");
                        break;
                    case 15:
                        signItemErrorRemark.setText("因终端派送车辆临时故障，导致货物派送延误，预计25日上午安排派送至客户处。");
                        break;
                    case 16:
                        signItemErrorRemark.setText("因此票货外包装严重破损，导致收货人拒收3件。");
                        break;
                    case 17:
                        signItemErrorRemark.setText("因货上未附相关货物明细（或无签收单；到货规格等与客户要求不一致），导致收货人拒收10件。");
                        break;
                }
            }
        });

    //初始化状态下拉框
    initSpinner(signItemErrorSpinner);

    //初始化图片选择
    initGridData(signInputErrorDgv);

        new AlertDialog.Builder(this)
                .setTitle("异常录入")
                .setView(view)
                .setNegativeButton("取消", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            dialogInterface.dismiss();
        }
    })
            .setPositiveButton("确定", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {

            HashMap<String,Object> params = new HashMap<>();
            params.put("SupplierCommissionID",order.getSupplierCommissionID());
            params.put("SupplierSubCommissionID",order.getSupplierSubCommissionID());
            params.put("WaybillID",order.getWaybillID());
            params.put("DefectType",mSpinnerDatas.get(signItemErrorSpinner.getSelectedIndex()).getIndex());
            params.put("Description",signItemErrorRemark.getText().toString().trim());
            params.put("UploadFileInfo", FileUtils.getIVJsonFile(OrderInputActivity.this, dataSourceList));
            params.put("CreateDescription", "");
            commitErrorOrder(params, order, OrderInputActivity.this);
        }
    })
            .show();
}

    private void initSpinner(MaterialSpinner signItemErrorSpinner) {
        mSpinnerDatas.clear();
        mSpinnerDatas.add(new SpinnerBeanCla("请选择",-1));
        mSpinnerDatas.add(new SpinnerBeanCla("联系方式错误",2));
        mSpinnerDatas.add(new SpinnerBeanCla("地址错误",3));
        mSpinnerDatas.add(new SpinnerBeanCla("收货人信息错误",4));
        mSpinnerDatas.add(new SpinnerBeanCla("窜货",6));
        mSpinnerDatas.add(new SpinnerBeanCla("丢失",7));
        mSpinnerDatas.add(new SpinnerBeanCla("破损",8));
        mSpinnerDatas.add(new SpinnerBeanCla("开单差错",9));
        mSpinnerDatas.add(new SpinnerBeanCla("签收单问题",10));
        mSpinnerDatas.add(new SpinnerBeanCla("等通知放货",11));
        mSpinnerDatas.add(new SpinnerBeanCla("服务变更",13));
        mSpinnerDatas.add(new SpinnerBeanCla("增\\减费用",14));
        mSpinnerDatas.add(new SpinnerBeanCla("始发站延误",16));
        mSpinnerDatas.add(new SpinnerBeanCla("干线延误",17));
        mSpinnerDatas.add(new SpinnerBeanCla("中转延误",18));
        mSpinnerDatas.add(new SpinnerBeanCla("派送延误",19));
        mSpinnerDatas.add(new SpinnerBeanCla("包装破损拒收",21));
        mSpinnerDatas.add(new SpinnerBeanCla("订单与实货不符",22));

        signItemErrorSpinner.setItems(mSpinnerDatas);




    }


    public void showSignDialog(final OrderBean order) {

        View view = View.inflate(this, R.layout.item_input_sign, null);
        TextView waybill = view.findViewById(R.id.sign_item_beteng_waybill);
        final AppCompatEditText signer = view.findViewById(R.id.sign_item_beteng_signer);
        final AppCompatEditText signTime = view.findViewById(R.id.sign_item_sign_time);
        final AppCompatEditText remark = view.findViewById(R.id.sign_item_beteng_remark);
        RecyclerView rv = view.findViewById(R.id.item_input_dgv);

        waybill.setText(order.getWaybillID() + "");
        signer.setText(order.getReceivePerson() + "");
        signTime.setText(DateTimeUtils.getDateWithFormat("yyyy-MM-dd HH:mm"));

        initGridData(rv);
        signTime.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {

                if (motionEvent.getAction() == MotionEvent.ACTION_UP) {

                    new TimePickerDialog.Builder()
                            .setCallBack(new OnDateSetListener() {
                                @Override
                                public void onDateSet(TimePickerDialog timePickerView, long millseconds) {
                                    signTime.setText(DateTimeUtils.getDateWithFormat("yyyy-MM-dd HH:mm", millseconds));
                                    timePickerView.dismiss();
                                }
                            })
                            .setCancelStringId("取消")
                            .setSureStringId("确定")
                            .setTitleStringId("请选择")
                            .setYearText("年")
                            .setMonthText("月")
                            .setDayText("日")
                            .setHourText("时")
                            .setMinuteText("分")
                            .setCyclic(false)
                            .setThemeColor(getResources().getColor(R.color.timepicker_dialog_bg))
                            .setType(Type.ALL)
                            .setWheelItemTextNormalColor(getResources().getColor(R.color.timetimepicker_default_text_color))
                            .setWheelItemTextSelectorColor(getResources().getColor(R.color.timepicker_toolbar_bg))
                            .setWheelItemTextSize(12)
                            .build()
                            .show(getSupportFragmentManager(), "month_day_hour_minute");
                }

                return true;
            }
        });


        new AlertDialog.Builder(this)
                .setTitle("签收录入")
                .setView(view)
                .setNegativeButton("取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        dialogInterface.dismiss();
                    }
                })
                .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        dialogInterface.dismiss();
                        HashMap<String, Object> params = new HashMap<>();
                        params.put("SupplierCommissionID", order.getSupplierCommissionID());
                        params.put("SupplierSubCommissionID", order.getSupplierSubCommissionID());
                        params.put("WaybillID", order.getWaybillID());
                        params.put("SignContactPerson", signer.getText().toString().trim());
                        params.put("SignDateTime", signTime.getText().toString().trim());
                        params.put("SignDescription", remark.getText().toString().trim());
                        params.put("SignDescription", remark.getText().toString().trim());
                        params.put("UploadFileInfo", FileUtils.getIVJsonFile(OrderInputActivity.this, dataSourceList));
                        commitSignOrder(params, order, OrderInputActivity.this);
                    }
                })
                .show();
    }


    private void initGridData(RecyclerView rv) {
        mImageViewadapter = new GridImageAdapter(this, new GridImageAdapter.onAddPicClickListener() {
            @Override
            public void onAddPicClick() {
                openImageSelete();
            }
        }, new GridImageAdapter.onDeletedPicClickListener() {
            @Override
            public void onDelPicClick(List<LocalMedia> list) {
                dataSourceList.clear();
                for (LocalMedia localMedia : list) {
                    dataSourceList.add(localMedia.getCompressPath());
                }
            }
        });
        rv.setLayoutManager(new FullyGridLayoutManager(this, 4, GridLayoutManager.VERTICAL, false));
        rv.setAdapter(mImageViewadapter);


        mImageViewadapter.setOnItemClickListener(new GridImageAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(int position, View v) {
                LocalMedia media = selectList.get(position);
                String pictureType = media.getPictureType();
                int mediaType = PictureMimeType.pictureToVideo(pictureType);
                switch (mediaType) {
                    case 1:
                        // 预览图片
                        PictureSelector.create(OrderInputActivity.this).externalPicturePreview(position, selectList);
                        break;
                    default:
                        break;

                }
            }
        });


    }

    private void openImageSelete() {
        PictureSelector.create(this)
                .openGallery(PictureMimeType.ofImage())// 全部.PictureMimeType.ofAll()、图片.ofImage()、视频.ofVideo()
                .theme(R.style.picture_default_style)//主题样式(不设置为默认样式) 也可参考demo values/styles下 例如：R.style.picture.white.style
                .maxSelectNum(10)// 最大图片选择数量 int
                .minSelectNum(0)// 最小选择数量 int
                .imageSpanCount(4)// 每行显示个数 int
                .selectionMode(PictureConfig.MULTIPLE)// 多选 or 单选 PictureConfig.MULTIPLE or PictureConfig.SINGLE
                .previewImage(true)// 是否可预览图片 true or false
                .previewVideo(false)// 是否可预览视频 true or false
                .compressGrade(Luban.FIRST_GEAR)// luban压缩档次，默认3档 Luban.THIRD_GEAR、Luban.FIRST_GEAR、Luban.CUSTOM_GEAR
                .isCamera(true)// 是否显示拍照按钮 ture or false
                .compress(true)// 是否压缩 true or false
                .compressMode(LUBAN_COMPRESS_MODE)//系统自带 or 鲁班压缩 PictureConfig.SYSTEM_COMPRESS_MODE or LUBAN_COMPRESS_MODE
                //.glideOverride() glide 加载宽高，越小图片列表越流畅，但会影响列表图片浏览的清晰度 int
                .isGif(false)// 是否显示gif图片 true or false
                .openClickSound(false)// 是否开启点击声音 true or false
                //.selectionMedia() 是否传入已选图片 List<LocalMedia> list
                .previewEggs(true)// 预览图片时 是否增强左右滑动图片体验(图片滑动一半即可看到上一张是否选中) true or false
                .compressMaxKB(100)//压缩最大值kb compressGrade()为Luban.CUSTOM_GEAR有效 int
                //.compressWH()  压缩宽高比 compressGrade()为Luban.CUSTOM_GEAR有效 int
                //.videoQuality() 视频录制质量 0 or 1 int
                //.videoSecond()显示多少秒以内的视频 int
                //.recordVideoSecond()录制视频秒数 默认60s int
                .forResult(PictureConfig.CHOOSE_REQUEST);//结果回调onActivityResult code
    }

    private void commitSignOrder(HashMap<String, Object> params, final OrderBean order, Context context){
        showLoading();
        SiteService.getInstants().commitSignOrder(params, context)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<BaseBean>() {
                    @Override
                    public void accept(BaseBean baseBean) throws Exception {
                        if (baseBean.isData()) {
                            mUsers.remove(order);
                            mAdapter.notifyDataSetChanged();
                            showMessageDialog("提交成功");
                            hideLoading();
                        }
                    }
                });

    }

    private void commitErrorOrder(HashMap<String, Object> params, OrderBean order, Context context) {
        showLoading();
        SiteService.getInstants().commitErrorOrder(params, context)
                .observeOn(Schedulers.io())
                .subscribeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<BaseBean>() {
                    @Override
                    public void accept(BaseBean baseBean) throws Exception {

                        showMessageDialog("提交成功");

                        hideLoading();
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        String message = throwable.getMessage();
                        showMessageDialog(message);
                    }
                });


    }

    private void showMessageDialog(String message) {
        new AlertDialog.Builder(this)
                .setTitle("提示")
                .setMessage(message)
                .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        dialogInterface.cancel();
                    }
                }).show();
    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if (resultCode == RESULT_OK) {
            switch (requestCode) {
                case PictureConfig.CHOOSE_REQUEST:
                    // 图片选择结果回调
                    selectList = PictureSelector.obtainMultipleResult(data);


//                     例如 LocalMedia 里面返回两种path
//                     1.media.getPath(); 为原图path
//                     2.media.getCompressPath();为压缩后path，需判断media.isCompressed();是否为true
                    dataSourceList.clear();
                    for (LocalMedia localMedia : selectList) {
                        dataSourceList.add(localMedia.getCompressPath());
                    }
                    mImageViewadapter.setList(selectList);
                    mImageViewadapter.notifyDataSetChanged();
                    break;
            }
        }
    }


}
